<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
			window.onload = function(){
				var inputs = document.getElementsByTagName('input');
				inputs[2].onclick = function(){
					var txtValue = inputs[0].value;
//					存储值
//			sessionStorage当当前窗口被关闭时,释放里面的值
//			localStorage 不局限于当前窗口,一直存在
					localStorage.setItem('txt',txtValue);
					inputs[0].value = '';
					localStorage.setItem('txt2',inputs[1].value);
					inputs[1].value = '';
					console.log(localStorage.length);
				}
				inputs[3].onclick = function(){
					inputs[0].value = localStorage.getItem('txt');
					inputs[1].value = localStorage.getItem('txt2');
				}
				inputs[4].onclick = function(){
					localStorage.removeItem('txt');
				}
				inputs[5].onclick = function(){
//					清空localStorage里面存储的所有键值对,即所有数据
					localStorage.clear();
				}
			}
		</script>
	</head>
	<body>
		<input type="text" name="" id="" />
		<input type="text" name="" id="" />
		<input type="button" value="存储" />
		<input type="button" value="还原" />
		<input type="button" value="清空txt1" />
		<input type="button" value="全部清除" />
		
	</body>
</html>
